<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui/css/layui.css" media="all">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body>

<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
    <legend>经纪人信息详情</legend>
</fieldset>
<form class="layui-form layui-form-pane" action="">

    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" name="username" id="agentname" placeholder="经纪人姓名"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别</label>
        <div class="layui-input-inline">
            <input type="text" name="username" id="sex" placeholder="经纪人性别"  autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">联系方式</label>
            <div class="layui-input-block">
                <input type="text" name="date" id="tel" maxlength="11" autocomplete="off" class="layui-input">
            </div>
        </div>

    </div>
    <div class="layui-form-item">
        <button class="layui-btn" lay-submit lay-filter="demo2" onclick="subform()">添加</button>
    </div>
</form>

<script rel="stylesheet" src="/lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="https://cdn.bootcss.com/jquery/1.11.2/jquery.js"></script>
<script th:inline="javascript">
    function subform() {
        $.ajax({
            url:"/agent/add",
            type:'post',
            data:{
                name:$("#agentname").val(),
                sex:$("#sex").val(),
                tel:$("#tel").val(),
            },
            dataType:'json',
            success:function (message) {
                if (message.code==0){
                    alert("添加成功！")
                }else {
                    alert("添加失败！")
                }
            }
        })
    }

</script>
</body>
</html>
